package com.example.hotelrear.controller;

import com.example.hotelrear.entity.Order;
import com.example.hotelrear.entity.ResponseResult;
import com.example.hotelrear.service.OrderService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author FengXiao
 * @since 2023-08-28
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @GetMapping("/personalCenter")
    public ResponseResult paid(@Param("id") int id) {
        int paid = orderService.paid(id);
        int notpaid = orderService.notpaid(id);
        int TobeComment = orderService.TobeComment(id);
        Map<String,Object> person=new HashMap<>();
        person.put("paid",paid);
        person.put("notpaid",notpaid);
        person.put("TobeComment",TobeComment);
        return ResponseResult.ok(person);
    }
    @GetMapping("/findAllOrderById")
    public ResponseResult findAllOrderById(@Param("id") int id) {
        List<Order> allOrderById = orderService.findAllOrderById(id);
        return ResponseResult.ok(allOrderById);
    }
    @GetMapping("/findNoPaidOrderById")
    public ResponseResult findNoPaidOrderById(@Param("id") int id) {
        List<Order> allOrderById = orderService.findNoPaidOrderById(id);
        return ResponseResult.ok(allOrderById);
    }
    @GetMapping("/findPaidOrderById")
    public ResponseResult findPaidOrderById(@Param("id") int id) {
        List<Order> allOrderById = orderService.findPaidOrderById(id);
        return ResponseResult.ok(allOrderById);
    }
    @GetMapping("/findNoCommentOrderById")
    public ResponseResult findNoCommentOrderById(@Param("id") int id) {
        List<Order> allOrderById = orderService.findNoCommentOrderById(id);
        return ResponseResult.ok(allOrderById);
    }
    @GetMapping("/findInactiveOrderById")
    public ResponseResult findInactiveOrderById(@Param("id") int id) {
        List<Order> allOrderById = orderService.findInactiveOrderById(id);
        return ResponseResult.ok(allOrderById);
    }
    @GetMapping("/findCancleOrderById")
    public ResponseResult findCancleOrderById(@Param("id") int id) {
        List<Order> allOrderById = orderService.findCancleOrderById(id);
        return ResponseResult.ok(allOrderById);
    }
}
